var optimizeCb = require("./01_optimizeCb");
var keys = require("./07_keys");
var isArrayLike = require("./15_isArrayLike");

function map(obj, iteratee, context) {
  iteratee = optimizeCb(iteratee);
  var ks = !isArrayLike(obj) && keys(obj),
    length = (ks || obj).length;
  result = Array(length);
  for (var i = 0; i < length; ++i) {
    const currentKey = ks ? ks[i] : i;
    result[i] = iteratee(obj[currentKey], currentKey, context);
  }
  return result;
}

module.exports = map;
